<?php include 'conf/base.php';?>

<?php $title = gettext("Publicar Anuncio Gratis"). " " .CIUDAD. " | ". gettext("Publicar Anuncio Clasificado Gratis"). " ". CIUDAD. " | ". gettext("Anuncios Locales")?>
<?php $descripcion = gettext("Publicar Anuncio Clasificado Compra Venta, Servicios, Turismo, Inmuebles, Vehiculos, etc")?>
<?php $keywords = gettext("Publicar Anuncio Clasificado Compra Venta, Servicios, Turismo, Inmuebles, Vehiculos, etc")?>

<?php include 'template_header_subdominios.php'?>
<?php include 'template_nav_bar_subdominios.php';?>
<?php include 'template/recurso_plupload.php'?>

<?php 
   if (isset($_POST['publicacion_id'])){
   	marcar_publicacion_como_completa($_POST['publicacion_id']);
   	registrar_mail_nueva_publicacion($_POST['publicacion_id']);
   	if (MODULO_PREMIM && !is_premium()){
   	$url = getResultadoPublicacionPath($_POST['publicacion_id']);
   	}else {
   	$url = getPublicacionPath($_POST['publicacion_id']);
   	}
    exit('<meta http-equiv="refresh" content="0; url=' . urldecode($url) . '"/>');	   	  
   }
   
   if (isset($_GET['id'])){
   	
   	$publicacion_valores = get_valores_publicacion($_GET['id'],  array("completa"));
   	
   	if ((int)$publicacion_valores['completa']==0){

?>

  <div class="container">
    <div class="row">       
        <div class="col-md-9">

	  <h2 class="section-title"><?php echo gettext("Segundo Paso")?> - <?php echo gettext("Subir Imágenes")?></h2>

	<br>
	<div class="alert alert-info">
		<p>1 - <?php echo gettext("Haga clic en seleccionar imágenes y seleccione las imágenes para su anuncio (máximo 5 imágenes)")?></p>
		<p>2 - <?php echo gettext("Haga clic en subir imágenes")?></p>
		<p>3 - <?php echo gettext("Cuando todas las imágenes estén subidas al 100%, haga clic en Finalizar")?></p>
		<p>4 - <?php echo gettext("NOTA: si no desea subir imágenes haga clic en finalizar directamente")?> </p>
	</div>
	
	<div id="container">
		<div id="filelist"><p><?php echo gettext("Su navegador no tiene soporte Flash, Silverlight, Gears, BrowserPlus o HTML5")?>.</p></div>
		<br /> <a id="pickfiles" href="javascript:;">[<?php echo gettext("Seleccionar Imágenes")?>]</a> <a
			id="uploadfiles" href="javascript:;">[<?php echo gettext("Subir Imágenes")?>]</a>
	</div>
	
	<br>
	
	<form method="POST">
	 <input type="hidden" id='result' name='result' value='OK'/>
	 <input type="hidden" id='publicacion_id' name='publicacion_id' value="<?php echo $_GET['id'];?>"/>
	 <div id="segundo_paso">
	 <input id='segundo_paso_submit' type='submit' value='<?php echo gettext("Finalizar")?>' class='btn btn-ar btn-primary'/>
	  </div>
	</form>

	
<script type="text/javascript">

				// Custom example logic
			function $ob(id) {
				return document.getElementById(id);	
			}

			
			
			var uploader = new plupload.Uploader({

				<?php 		
				
				$user_agent = $_SERVER['HTTP_USER_AGENT'];
				
				if (preg_match('/MSIE/i', $user_agent)) {
					echo "runtimes : 'html4',";
				} else {
					echo "runtimes : 'gears,html5,flash,silverlight,browserplus,html4',";
				};
				
				?>	
									
				browse_button : 'pickfiles',
				container: 'container',
				max_file_size : '10mb',			
				chunk_size : '512kb',					
				unique_names : true,	
				url : 'upload.php',
				flash_swf_url : '../../plupload/js/plupload.flash.swf',
				silverlight_xap_url : '../../plupload/js/plupload.silverlight.xap',
				filters : [
					{title : "Image files", extensions : "jpg,gif,png"}	
				]
			});
			
			uploader.bind('Init', function(up, params) {
				$ob('filelist').innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
			});
			
			uploader.bind('FilesAdded', function(up, files) {
				for (var i in files) {					
					$ob('filelist').innerHTML += '<div class=item_nueva_imagen id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
				}
			});
			
			uploader.bind('UploadProgress', function(up, file) {
				$ob(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
			});
			
			$ob('uploadfiles').onclick = function() {
				uploader.start();
				return false;
			};
			
			uploader.init();
</script>

</div>

<?php
}
   	 else {

    echo "
                         <div class='alert alert-danger'>
                         <button type='button' class='close' data-dismiss='alert'>×</button>
                         <strong>".gettext("Ya se ha completado la publicación de este anuncio")."</strong>
                         </div>"; 
 
     }     
   }

?>

</div>
</div>

<?php include 'template_footer_subdominios.php'?>
<?php include 'template_side_bar_subdominios.php';?>

<!-- Scripts -->
<!-- Compiled in vendors.js -->
<!--
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/js/imagesloaded.pkgd.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bootstrap-switch.min.js"></script>
<script src="assets/js/wow.min.js"></script>
<script src="assets/js/slidebars.min.js"></script>
<script src="assets/js/jquery.bxslider.min.js"></script>
<script src="assets/js/holder.js"></script>
<script src="assets/js/buttons.js"></script>
<script src="assets/js/jquery.mixitup.min.js"></script>
<script src="assets/js/circles.min.js"></script>
<script src="assets/js/masonry.pkgd.min.js"></script>
<script src="assets/js/jquery.matchHeight-min.js"></script>
-->

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/vendors.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/funcionesjs.js"></script>

<!-- Syntaxhighlighter -->
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shCore.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushXml.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushJScript.js"></script>

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/app.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/index.js"></script>

</body>

</html>
